﻿using System.Data;
using System;
// Copyright © Microsoft Corporation.  All Rights Reserved.
// This code released under the terms of the 
// Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)

using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using SongSharp;
using SongSharp.Domain.Events;
using SongSharp.Domain.Queueing;
using SongSharp.Domain.Objects;
using SongSharp.Presentation.Adapter;

namespace SongSharp.Presentation.View
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class PrimeView : Window
    {
        public PrimeView()
        {
            InitializeComponent();

            // Windows aero design init
            this.Loaded += (s, e) =>
            {
                Helper.Aero.GlassEffectHelper.EnableGlassEffect(this);
            };
            Helper.ImageButton.ImageButtonManager.Init(this);
        }

        #region Multistate buttons Todo
        private void imageRepeat_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.RepeatButton.Press();
        }

        private void imageRepeat_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.RepeatButton.NextState();
        }

        private void imageNext_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.NextButton.Press();
            ((ISongSharpWindowCommands)DataContext).PlayerNextBtn_Click(sender, e);
        }

        private void imageNext_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.NextButton.NextState();
        }

        private void imagePrevious_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PrevButton.Press();
            ((ISongSharpWindowCommands)DataContext).PlayerPreviousBtn_Click(sender, e);
        }

        private void imagePrevious_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PrevButton.NextState();
        }

        private void imageRandom_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.RandomButtom.Press();
        }

        private void imageRandom_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.RandomButtom.NextState();
        }

        private void imagePlayOnce_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PlayOnceButton.Press();
        }

        private void imagePlayOnce_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PlayOnceButton.NextState();
        }

        private void imagePause_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PauseButton.Press();
        }

        private void imagePause_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Helper.ImageButton.ImageButtonManager.PauseButton.NextState();
            ((ISongSharpWindowCommands)DataContext).PlayerPauseBtn_Click(sender, e);
        }
        #endregion

        private void TrackView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).Tracklist_DoubleClick(sender, e);
        }

        private void PlaylistView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).Playlist_DoubleClick(sender, e);
        }

        private void PlaylistView_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).Playlist_Click(sender, e);
        }

        private void TrackView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).Tracklist_Click(sender, e);
        }

        private void Window_Closed(object sender, EventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).OnClose(sender, e);
        }

        private void TrackView_Drop(object sender, DragEventArgs e)
        {
            e.Effects = DragDropEffects.Copy;
            ((ISongSharpWindowCommands)DataContext).Tracklist_Drop(sender, e);
        }

        private void PlaylistView_Drop(object sender, DragEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).Playlist_Drop(sender, e);
        }

        private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            ((ISongSharpWindowCommands)DataContext).PlayerTrackbar_ValueChanged(sender, e);
        }

        private void sliderVolume_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            ((ISongSharpWindowCommands)DataContext).PlayerVolume_ValueChanged(sender, e);
        }

        private void textBlockRefreshMusicStream_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).PlayerSuggestMusicStream_Click(sender, e);
        }

        private void textBlockOpenConsole_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            ((ISongSharpWindowCommands)DataContext).PlayerOpenLogWindow_Click(sender, e);
        }

    }
}
